#!/usr/bin/env make
###############################################################################
#
#  Copyright (c) Hunan Goke,Chengdu Goke,Shandong Goke. 2021.
#  All rights reserved.
#  Create By Caizhiyong 2021/3/16
#
###############################################################################
DOSFS       := dosfstools-3.0.28

DOSFS_PREFIX = $(ROOTFS_BUILDDIR)/$(DOSFS)

CC := $(CROSS_COMPILE)-gcc

rootfs_unstrip: $(ROOTFS_PREFIX)/sbin/fsck.fat

clean: $(DOSFS).clean

$(DOSFS).clean:
	rm -rf $(ROOTFS_BUILDDIR)/$(DOSFS)

$(ROOTFS_PREFIX)/sbin/fsck.fat: $(ROOTFS_BUILDDIR)/$(DOSFS)/.built
	$(call mkdir,$(@D))
	cd $(DOSFS_PREFIX); ln -sf fsck.fat dosfsck
	cp -arf $(DOSFS_PREFIX)/dosfsck $(ROOTFS_PREFIX)/sbin
	cp -arf $(DOSFS_PREFIX)/fsck.fat $(ROOTFS_PREFIX)/sbin
	cp -arf $(DOSFS_PREFIX)/mkfs.fat $(ROOTFS_PREFIX)/sbin
	touch $@

$(DOSFS_PREFIX)/.built: $(DOSFS_PREFIX)/.extracted
	make -C $(<D) CC=$(CC)
	touch $@

$(DOSFS_PREFIX)/.extracted:
	$(call mkdir,$(@D))
	tar xf $(OPEN_SOURCE_DIR)/dosfstools/$(DOSFS).tar.gz -C $(ROOTFS_BUILDDIR)
	touch $@

